package demo.huodongbaoming.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 用户活动控制器
 * 为失物招领系统提供用户活动数据的API
 */
@RestController
@RequestMapping("/api/activities")
public class UserActivityController {

    /**
     * 获取用户参与的活动
     * @param userId 用户ID
     * @return 活动列表
     */
    @GetMapping("/user/{userId}")
    public List<Map<String, Object>> getUserActivities(@PathVariable("userId") Long userId) {
        // 模拟从数据库获取数据
        List<Map<String, Object>> activities = new ArrayList<>();
        
        // 添加一些模拟数据
        activities.add(createActivity(1L, "校园志愿者服务", "2023-06-10", "已完成", userId));
        activities.add(createActivity(2L, "迎新晚会", "2023-09-15", "已报名", userId));
        activities.add(createActivity(3L, "学术讲座", "2023-10-20", "进行中", userId));
        activities.add(createActivity(4L, "运动会", "2023-11-05", "未开始", userId));
        
        return activities;
    }
    
    /**
     * 创建活动数据
     */
    private Map<String, Object> createActivity(Long id, String name, String date, String status, Long userId) {
        Map<String, Object> activity = new HashMap<>();
        activity.put("id", id);
        activity.put("name", name);
        activity.put("date", date);
        activity.put("status", status);
        activity.put("userId", userId);
        return activity;
    }
} 